package com.mercury.console.controller;

import com.mercury.file.upload.local.LocalUpload;
import com.mercury.file.upload.local.pojo.UploadFileParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * @author mercury
 */
@Slf4j
@RestController
public class ConsoleController {

    @Value("${file.save-paxth:/data-center/files/vip-file-manager}")
    private String savePath;
    @Value("${file.conf-path:/data-center/files/vip-file-manager/conf}")
    private String confFilePath;


    /**
     * 断点续传方式上传文件：用于大文件上传
     *
     * @param param   参数
     * @param request 请求
     */
    @ApiOperation("断点续传")
    @PostMapping(value = "/breakpoint-upload", consumes = "multipart/*", headers = "content-type=multipart/form-data", produces = "application/json;charset=UTF-8")
    public void breakpointResumeUpload(UploadFileParam param, HttpServletRequest request) {
        try {
            LocalUpload.fragmentFileUploader(param, confFilePath, savePath, 5242880L, request);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }



}